package com.freemyleft.left.zapp.selectimage;

import android.app.Activity;
import android.content.Intent;




import com.freemyleft.left.zapp.selectimage.activity.ImageSelectPhotoActivity;
import com.freemyleft.left.zapp.selectimage.listener.CameraListener;
import com.freemyleft.left.zapp.selectimage.listener.SelectImageFinishListener;


/**
 * Created by Administrator on 2017/6/6.
 */
public class ImageSelectUtils {
    private Activity mActivity;
    private int mSelectImageCount = 1;
    private boolean mIsSingleClip = false;
    private int mCutWidth = 0;
    private int mCutHight = 0;
    public ImageSelectUtils setOnSelectImageFinishListener(SelectImageFinishListener listener ){
        if (mIsSingleClip)return this;
        ImageSelectPhotoActivity.setSelectImageFinishListener(listener);
        return this;
    }

    public ImageSelectUtils(Activity activity){
        mActivity = activity;

    }
    /**选择图片数量*/
    public ImageSelectUtils setSelectImageNum(int count){
        mSelectImageCount = count;
        return this;
    }

    /**设置裁剪*/
    public ImageSelectUtils setSingleImageClip( int cutWidth, int cutHight, CameraListener listener){
        mSelectImageCount = 1;
        mIsSingleClip = true;
        mCutWidth = cutWidth;
        mCutHight = cutHight;
        ImageSelectPhotoActivity.setCameraListener(listener);
        ImageSelectPhotoActivity.setSelectImageFinishListener(null);
        return this;
    }

    public void start(){
        if (new PermissionsUtils(mActivity).getPermissionRead()){
            return;
        }
        Intent intent = new Intent(mActivity, ImageSelectPhotoActivity.class);
        intent.putExtra("count", mSelectImageCount);
        intent.putExtra("is_clip", mIsSingleClip);
        intent.putExtra("cut_width", mCutWidth);
        intent.putExtra("cut_hight", mCutHight);
        mActivity.startActivity(intent);
    }
}
